package com.ymatou.iapi.godmch.testcase;

import java.text.SimpleDateFormat;
import java.util.Arrays;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.json.JSONException;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import com.ymatou.iapi.dguser.parameter.UserCreateBean;
import com.ymatou.iapi.godmch.parameter.CreateCodeBean;
import com.ymatou.iapi.godmch.parameter.MchInfoVo;
import com.ymatou.iapi.godmch.parameter.applyAgentBean;
import com.ymatou.iapi.godmch.parameter.approveAgentBean;
import com.ymatou.iapi.godmch.parameter.bindmchBean;
import com.ymatou.iapi.godmch.parameter.createIndepMchBean;
import com.ymatou.iapi.godmch.parameter.createagentBean;
import com.ymatou.iapi.godmch.parameter.createmchBean;
import com.ymatou.iapi.godmch.parameter.listbyidmchBean;
import com.ymatou.iapi.godmch.parameter.setShareTypeBean;
import com.ymatou.iapi.godmch.service.CreateCodeCall;
import com.ymatou.iapi.godmch.service.applyAgentCall;
import com.ymatou.iapi.godmch.service.createIndepMchCall;
import com.ymatou.iapi.godmch.service.createagentCall;
import com.ymatou.iapi.godmch.service.listbyidmchCall;
import com.ymatou.iapi.godmch.service.setShareTypeCall;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.*;
import com.ymt.utils.tag.*;
import com.ymttest.business.service.DGUserCallService;
import com.ymttest.business.service.shenqi.GodmchManageCallService;
import com.ymttest.database.model.agent_type;
import com.ymttest.database.model.country_info;
import com.ymttest.database.model.mch_info;
/**
*商户信息(批量)
*FreeMaker Template自动生成代码
*/
import com.ymttest.database.sqlwapper.godmch.DefGodMchWapper;
import com.ymttest.database.sqlwapper.godmch.mch_infoWapper;
import com.ymttest.utils.EnvSetup;
@TestSuite
public class Ts_listbyidmch{
	private static listbyidmchBean listbyidmchbean;
	private static listbyidmchCall listbyidmchcall;
	
	private  setShareTypeBean shareTypeBbean=new setShareTypeBean();
	private  setShareTypeCall shareTypeCall=new setShareTypeCall();
	 mch_infoWapper mchInfoWapper=new mch_infoWapper();
	 
	DefGodMchWapper DefGodMchWapper;
	
	Integer masterChainShopId_wechatDirectPayMode=Integer.parseInt(EnvSetup.getData("masterChainShopId_wechatDirectPayMode"));
	
	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("商户信息(批量)");
	}

	@Before
	public void caseUp() {
		listbyidmchbean=new listbyidmchBean();
		listbyidmchcall=new listbyidmchCall();
		DefGodMchWapper=new DefGodMchWapper();
	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(listbyidmchcall.getOpurl());
	}

	@After
	public void caseDown() {
		Logger.end();
	}
	private void checkVerify(List<Integer> mchIds,boolean...indepMchSelf) throws InterruptedException, JSONException
	{
		for (Integer mchId : mchIds) {
			List<MchInfoVo> rminfos = listbyidmchcall.getResult();                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 
			MchInfoVo rminfo =null;
			try {
				rminfo = rminfos.stream().filter(r->r.getMchId().equals(mchId)).findFirst().get();
			}catch (Throwable e) {
				continue;
			}
			mch_info dbmchinfo = DefGodMchWapper.selectMchInfo(mchId).get(0);
			country_info dbCountryInfo = DefGodMchWapper.selectCountryInfo(rminfo.getCountryCode(),null).get(0);
			//用户信息
			Logger.verifyEquals(dbmchinfo.getAgent()==1?true:false, rminfo.getAgent(), "验证Agent");
			Logger.verifyEquals(dbmchinfo.getVip()==1?true:false, rminfo.getVip(), "验证vip");
			Logger.verifyEquals(dbmchinfo.getChannels()==1?true:false, rminfo.getChannel(), "验证getChannels");
			Logger.verifyEquals(dbmchinfo.getVip()==1?true:false, rminfo.getVip(), "验证Vip");
			Logger.verifyEquals(dbmchinfo.getAvatar(), rminfo.getAvatar(), "验证Avatar");
			Logger.verifyEquals(dbmchinfo.getMchTitle()==null||dbmchinfo.getMchTitle().length()==0?dbmchinfo.getNickName():dbmchinfo.getMchTitle(), rminfo.getMchTitle(), "验证MchTitle");
			Logger.verifyEquals(dbmchinfo.getSeqId(), rminfo.getSeqId(), "验证SeqId");
			//国家信息
			Logger.verifyEquals(dbCountryInfo.getCnTitle(), rminfo.getCountry(), "验证Country");
			Logger.verifyEquals(dbCountryInfo.getCountry(), rminfo.getCountryCode(), "验证CountryCode");
			Logger.verifyEquals(dbCountryInfo.getCurrency(), rminfo.getCurrency(), "验证Currency");
			Logger.verifyEquals(dbCountryInfo.getFlag(), rminfo.getFlag(), "验证Flag");
			
			
			//Status 1：正常 2：下架（独立小程序特有状态，指公共小程序下架，切换时间到过期时间这段时间） 3：打烊（独立小程序特有状态，指独立小程序，过期时间后）
			if(rminfo.getExpiredTime()!=null )
			{
				Date date = new Date();
				if(dbmchinfo.getSwitchIndeMiniAppTime()==null && rminfo.getParentMchId()!=null)
				{
					mch_info infos=DefGodMchWapper.selectMchInfo(Integer.parseInt(rminfo.getParentMchId())).get(0);
					date=infos.getSwitchIndeMiniAppTime();
				}
				else {
					 date = dbmchinfo.getSwitchIndeMiniAppTime();//取时间 
				}
				SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd") ;
			    Calendar calendar  =   Calendar.getInstance();
			    calendar.setTime(date); //需要将date数据转移到Calender对象中操作
			    calendar.add(calendar.DATE, 6);//把日期往后增加n天.正数往后推,负数往前移动 
			    date=calendar.getTime();   //这个时间就是日期往后推一天的结果 
			    Logger.verifyEquals(dateFormat.format(date), rminfo.getExpiredTime(), "验证ExpiredTime,往后延迟多少天过期，是根据dizconfig配置，目前研发配置7天，包括当天");
			}
			else
				Logger.verifyEquals(1, rminfo.getStatus(), "验证Status");
			
			Logger.verifyEquals(dbmchinfo.getPayMode(),rminfo.getPayMode(), "验证PayMode");
			//商户类型 1：平台商户     2：独立商户
			Logger.verifyEquals(dbmchinfo.getMchType(),rminfo.getMchType(), "验证mchType");
			//支付宝支付方式 新增20191224
			Logger.verifyEquals(0,rminfo.getAliPayMode(), "验证AliPayMode");
			Logger.verifyEquals(dbmchinfo.getAliPayMode(),rminfo.getAliPayMode(), "验证AliPayMode");
			//dualMode 双店模式 0：正常模式 1：双店模式
			Logger.verifyEquals(dbmchinfo.getDualMode(),rminfo.getDualMode(), "验证DualMode");
			//买家端客服新增20200317
			//买家端客服是否开启
			Logger.verifyEquals(dbmchinfo.getBuyerCsEnabled(),rminfo.getBuyerCsEnabled(), "验证BuyerCsEnabled");
			//买家端客服微信号
			Logger.verifyEquals(dbmchinfo.getBuyerCsWechat(),rminfo.getBuyerCsWechat(), "验证BuyerCsWechat");
			//payChannel 1：hipoPay 2：盛付通  新增20200324
			Logger.verifyEquals(dbmchinfo.getPayMode()==3?2:1,rminfo.getPayChannel(), "验证PayChannel");
			//是否独立商户主账号 20200326
			Logger.verifyEquals(dbmchinfo.getIndepMchFlg()==1?true:false, rminfo.getIndepMchSelf(), "验证是否独立商户主账号 indepMchSelf");
		    //新增 20200407
			Logger.verifyEquals(dbmchinfo.getSettlementCurrency(),rminfo.getSettlementCurrency(), "验证SettlementCurrency");
			Logger.verifyEquals(dbmchinfo.getPayMode(),rminfo.getPayMode(), "验证PayMode");
			Logger.verifyEquals(dbmchinfo.getDomesticPayMode(),rminfo.getDomesticPayMode(), "验证DomesticPayMode");
			Logger.verifyEquals(dbmchinfo.getPulishDomestic()==0?false:true,rminfo.getPulishDomestic(), "验证PulishDomestic");
			
		    //20201020 新增
			Logger.verifyEquals(dbmchinfo.getYabandPayMode(),rminfo.getYabandPayMode(), "验证YabandPayMode");
			
		    //20201027 新增字段  masterChainShopId连锁店、wechatDirectPayMode微信直连
			Logger.verifyEquals(dbmchinfo.getWechatDirectPayMode(),rminfo.getWechatDirectPayMode(), "验证WechatDirectPayMode");
			Logger.verifyEquals(dbmchinfo.getMasterChainShopId(),rminfo.getMasterChainShopId(), "验证MasterChainShopId");
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_listbyidmch_001() {
		Logger.start(true,"商户信息(批量),验证商户ids集合都存在,返回成功");
		try {
//			String title="title1";
//			String wc="wc2";
//			CreateCodeBean ccbean = GodmchManageCallService.CreateAllMsgSellerMch();
//			String code = GodmchManageCallService.createCodeCall(ccbean).getCode();
//			Integer agentid = GodmchManageCallService.CreateSellerMch(code);
//			GodmchManageCallService.editMchInfo(ccbean.getMchId(),title, DGUserCallService.DefImg2,wc);
//			
//			listbyidmchbean.setMchIds(Arrays.asList(ccbean.getMchId()));
			listbyidmchbean.setMchIds(Arrays.asList(501411612));
			listbyidmchcall.setData(listbyidmchbean);
			listbyidmchcall.callService();			
			Logger.verifyEquals("200", listbyidmchcall.getString("status"), "验证status");
			checkVerify(listbyidmchbean.getMchIds());
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_listbyidmch_002() {
		Logger.start(true,"商户信息(批量),验证商户ids集合含有不存在的商户Id,返回失败,提示不存在的商户id");
		try {
			String title="title1";
			String wc="wc2";
			CreateCodeBean ccbean = GodmchManageCallService.CreateAllMsgSellerMch();
			String code = GodmchManageCallService.createCodeCall(ccbean).getCode();
			Integer agentid = GodmchManageCallService.CreateSellerMch(code);
			GodmchManageCallService.editMchInfo(ccbean.getMchId(),title, DGUserCallService.DefImg2,wc);
			listbyidmchbean.setMchIds(Arrays.asList(-1,ccbean.getMchId()));
			listbyidmchcall.setData(listbyidmchbean);
			listbyidmchcall.callService();			
			Logger.verifyEquals("200", listbyidmchcall.getString("status"), "验证status");
			checkVerify(listbyidmchbean.getMchIds());
			Logger.verifyEquals(1,listbyidmchcall.getResult().size(), "验证只返回1个有效的数据");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_listbyidmch_003() {
		Logger.start(true,"商户信息(批量),验证商户ids集合中的商户id都不存在,返回失败,提示错误");
		try {
			listbyidmchbean.setMchIds(Arrays.asList(-1));
			listbyidmchcall.setData(listbyidmchbean);
			listbyidmchcall.callService();			
			Logger.verifyEquals("200", listbyidmchcall.getString("status"), "验证status");
			Logger.verifyEquals(true,listbyidmchcall.getResult().isEmpty(), "验证空返回");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_listbyidmch_004() {
		Logger.start(true,"商户信息(批量),验证客服id空,返回失败");
		try {
			String title="title1";
			String wc="wc2";
			CreateCodeBean ccbean = GodmchManageCallService.CreateAllMsgSellerMch();
			GodmchManageCallService.SetVip(ccbean.getMchId());
			UserCreateBean usercreateBean = DGUserCallService.initCsUsercreateBean();
			int csId = DGUserCallService.UserCreateCall(usercreateBean);
			GodmchManageCallService.CreateCSCall(ccbean.getMchId(), csId, 4);
			GodmchManageCallService.EditCsRemark(ccbean.getMchId(), csId, "remakr1");
			Logger.comment("创建渠道商客服:" + csId);
			listbyidmchbean.setMchIds(Arrays.asList(csId));
			listbyidmchcall.setData(listbyidmchbean);
			listbyidmchcall.callService();			
			Logger.verifyEquals("200", listbyidmchcall.getString("status"), "验证status");
			Logger.verifyEquals(true,listbyidmchcall.getResult().isEmpty(), "验证空返回");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_listbyidmch_005() {
		Logger.start(true,"商户信息(批量),验证商户ids集合都存在-包含多个商户包含渠道和代理,返回成功");
		try {
			String title="title1";
			String wc="wc2";
			CreateCodeBean ccbean = GodmchManageCallService.CreateAllMsgSellerMch();
			String code = GodmchManageCallService.createCodeCall(ccbean).getCode();
			Integer agentid = GodmchManageCallService.CreateSellerMch(code);
			GodmchManageCallService.editMchInfo(ccbean.getMchId(),title, DGUserCallService.DefImg2,wc);
			listbyidmchbean.setMchIds(Arrays.asList(ccbean.getMchId(),agentid));
			listbyidmchcall.setData(listbyidmchbean);
			listbyidmchcall.callService();			
			Logger.verifyEquals("200", listbyidmchcall.getString("status"), "验证status");
			checkVerify(listbyidmchbean.getMchIds());
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	

	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_listbyidmch_006() {
		Logger.start(true,"商户信息(批量),验证商户ids集合都存在,其中一个商户 小程序切换 成独立小程序，mchShareType=1 变为 mchShareType=3 ");
		try {
			String title="title1";
			String wc="wc2";
			CreateCodeBean ccbean = GodmchManageCallService.CreateAllMsgSellerMch();
			String code = GodmchManageCallService.createCodeCall(ccbean).getCode();
			Integer agentid = GodmchManageCallService.CreateSellerMch(code);
			GodmchManageCallService.editMchInfo(ccbean.getMchId(),title, DGUserCallService.DefImg2,wc);
			
			//公共小程序切换 成独立小程序
			shareTypeBbean.setMchId(ccbean.getMchId());
			shareTypeBbean.setMchShareType(3);//独立小程序
			shareTypeBbean.setMchStatus(0);
			shareTypeBbean.setRemark("小程序 变为独立小程序");
			//新字段
			shareTypeBbean.setPayMode(1);//支付方式:微信支付通道1：飞界国际2：飞界国际电子商务3：盛付通
			shareTypeBbean.setMchSideBuy(1);//商家端购买1：二维码购买 2：直接购买
			shareTypeBbean.setDualMode(0);//双店模式0：正常模式（默认）1：双店模式
			
			shareTypeCall.setData(shareTypeBbean);
			shareTypeCall.callService();
			
			listbyidmchbean.setMchIds(Arrays.asList(ccbean.getMchId()));
			listbyidmchcall.setData(listbyidmchbean);
			listbyidmchcall.callService();			
			Logger.verifyEquals("200", listbyidmchcall.getString("status"), "验证status");
			checkVerify(listbyidmchbean.getMchIds());
			Logger.verifyNotNull( listbyidmchcall.getResult().get(0).getExpiredTime(), "验证ExpiredTime");
			Logger.verifyEquals(2, listbyidmchcall.getResult().get(0).getStatus(), "验证Status");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_listbyidmch_007() {
		Logger.start(true,"商户信息(批量),验证商户ids集合都存在,商户 小程序切换h5，mchShareType=1 变为 mchShareType=2");
		try {
			String title="title1";
			String wc="wc2";
			CreateCodeBean ccbean = GodmchManageCallService.CreateAllMsgSellerMch();
			String code = GodmchManageCallService.createCodeCall(ccbean).getCode();
			Integer agentid = GodmchManageCallService.CreateSellerMch(code);
			GodmchManageCallService.editMchInfo(ccbean.getMchId(),title, DGUserCallService.DefImg2,wc);
			
			//公共小程序切换 成独立小程序
			shareTypeBbean.setMchId(ccbean.getMchId());
			shareTypeBbean.setMchShareType(2);//H5
			shareTypeBbean.setMchStatus(0);
			shareTypeBbean.setRemark("小程序 变为独立小程序");
			shareTypeCall.setData(shareTypeBbean);
			shareTypeCall.callService();
			
			listbyidmchbean.setMchIds(Arrays.asList(ccbean.getMchId()));
			listbyidmchcall.setData(listbyidmchbean);
			listbyidmchcall.callService();	
			
			Logger.verifyEquals("200", listbyidmchcall.getString("status"), "验证status");
			Logger.verifyIsNull( listbyidmchcall.getResult().get(0).getExpiredTime(), "验证ExpiredTime");
			
			checkVerify(listbyidmchbean.getMchIds());
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_listbyidmch_008() {
		Logger.start(true,"商户信息(批量),验证商户ids集合都存在,其中一个商户 小程序切换 成独立小程序，mchShareType=1 变为 mchShareType=3 ,返回status=3 打烊（独立小程序特有状态，指独立小程序，过期时间后）");
		try {
			String title="title1";
			String wc="wc2";
			CreateCodeBean ccbean = GodmchManageCallService.CreateAllMsgSellerMch();
			String code = GodmchManageCallService.createCodeCall(ccbean).getCode();
			Integer agentid = GodmchManageCallService.CreateSellerMch(code);
			GodmchManageCallService.editMchInfo(ccbean.getMchId(),title, DGUserCallService.DefImg2,wc);
			
			//公共小程序切换 成独立小程序
			shareTypeBbean.setMchId(ccbean.getMchId());
			shareTypeBbean.setMchShareType(3);//独立小程序
			shareTypeBbean.setMchStatus(0);
			shareTypeBbean.setRemark("小程序 变为独立小程序");
			//新字段
			shareTypeBbean.setPayMode(1);//支付方式:微信支付通道1：飞界国际2：飞界国际电子商务3：盛付通
			shareTypeBbean.setMchSideBuy(1);//商家端购买1：二维码购买 2：直接购买
			shareTypeBbean.setDualMode(0);//双店模式0：正常模式（默认）1：双店模式
			shareTypeCall.setData(shareTypeBbean);
			shareTypeCall.callService();
			//更改时间
			Date date = new Date();//取时间 
		    Calendar calendar  =   Calendar.getInstance();
		    calendar.setTime(date); //需要将date数据转移到Calender对象中操作
		    calendar.add(calendar.DATE, -6);//把日期往后增加n天.正数往后推,负数往前移动 
		    date=calendar.getTime();   //这个时间就是日期往后推一天的结果 
		    
			mch_info mchinfo=DefGodMchWapper.selectMchInfo(ccbean.getMchId()).get(0);
			mchinfo.setSwitchIndeMiniAppTime(date);
			mchInfoWapper.updateByPrimaryKey(mchinfo);
			
			listbyidmchbean.setMchIds(Arrays.asList(ccbean.getMchId()));
			listbyidmchcall.setData(listbyidmchbean);
			listbyidmchcall.callService();	
			
			Logger.verifyEquals("200", listbyidmchcall.getString("status"), "验证status");
			Logger.verifyEquals(3, listbyidmchcall.getResult().get(0).getStatus(), "验证Status");
			Logger.verifyNotNull( listbyidmchcall.getResult().get(0).getExpiredTime(), "验证ExpiredTime");
			
			checkVerify(listbyidmchbean.getMchIds());
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_listbyidmch_009() {
		Logger.start(true,"商户信息(批量),验证商户ids集合都存在,其中一个商户 小程序切换 成独立小程序，mchShareType=1 变为 mchShareType=3 ");
		try {
			String title="title1";
			String wc="wc2";
			//商户1
			CreateCodeBean ccbean = GodmchManageCallService.CreateAllMsgSellerMch();
			String code = GodmchManageCallService.createCodeCall(ccbean).getCode();
			Integer agentid = GodmchManageCallService.CreateSellerMch(code);
			GodmchManageCallService.editMchInfo(ccbean.getMchId(),title, DGUserCallService.DefImg2,wc);
			//商户2
			CreateCodeBean ccbean2 = GodmchManageCallService.CreateAllMsgSellerMch();
			String code2 = GodmchManageCallService.createCodeCall(ccbean2).getCode();
			Integer agentid2 = GodmchManageCallService.CreateSellerMch(code2);
			GodmchManageCallService.editMchInfo(ccbean2.getMchId(),title, DGUserCallService.DefImg2,wc);
			
			//公共小程序切换 成独立小程序
			shareTypeBbean.setMchId(ccbean.getMchId());
			shareTypeBbean.setMchShareType(3);//独立小程序
			shareTypeBbean.setMchStatus(0);
			shareTypeBbean.setRemark("小程序 变为独立小程序");
			//新字段
			shareTypeBbean.setPayMode(1);//支付方式:微信支付通道1：飞界国际2：飞界国际电子商务3：盛付通
			shareTypeBbean.setMchSideBuy(1);//商家端购买1：二维码购买 2：直接购买
			shareTypeBbean.setDualMode(0);//双店模式0：正常模式（默认）1：双店模式
			shareTypeCall.setData(shareTypeBbean);
			shareTypeCall.callService();
			
			listbyidmchbean.setMchIds(Arrays.asList(ccbean.getMchId(),ccbean2.getMchId()));
			listbyidmchcall.setData(listbyidmchbean);
			listbyidmchcall.callService();			
			Logger.verifyEquals("200", listbyidmchcall.getString("status"), "验证status");
			checkVerify(listbyidmchbean.getMchIds());
			Logger.verifyNotNull( listbyidmchcall.getResult().get(0).getExpiredTime(), "验证ExpiredTime");
			Logger.verifyEquals(2, listbyidmchcall.getResult().get(0).getStatus(), "验证Status");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	
	
	@Test
	@Category({P1.class})
	@TestCase
	@Ignore
	public void Tc_listbyidmch_010() {
		//分享类型切换限制，公共版商家的分享类型去掉选项 “独立小程序继承版”，公共版商家不让使用这个选项
		//页面隐藏 “独立小程序继承版”,若出现异常选择了“5：独立小程序继承版”，程序自动不更新，保持原来的分享类型
		Logger.start(true,"商户信息(批量),验证商户ids集合都存在,创建代理-小程序切换 成独立小程序，mchShareType=1 变为 mchShareType=5,返回上级商户Id parentMchId,渠道设置5后，下面的子代理都更新为5 作废 ");
		try {
			
			//代理用户
			UserCreateBean usercreateBean = DGUserCallService.initSellerUsercreateBean();
			int mchId = DGUserCallService.UserCreateCall(usercreateBean);
			usercreateBean = DGUserCallService.initSellerUsercreateBean();
			int mchId_agent = DGUserCallService.UserCreateCall(usercreateBean);
			
			CreateCodeBean codebean=GodmchManageCallService.CreateAllMsgSellerMch();
			codebean.setIsPermanently(false);
			CreateCodeCall codeCall=GodmchManageCallService.createCodeCall(codebean);
			//创建渠道1
			createmchBean createBean1=GodmchManageCallService.InitcreatemchBeanForChannel(mchId);
			GodmchManageCallService.createmchCallForChannel(createBean1);
			//渠道1 邀请码
			CreateCodeBean createCodeBean=GodmchManageCallService.InitcreateCodeBeanForAgent(mchId, true);
			CreateCodeCall createCodeCall=GodmchManageCallService.createCodeCall(createCodeBean);
			//创建渠道2
		    createBean1=GodmchManageCallService.InitcreatemchBeanForChannel(mchId_agent);
			GodmchManageCallService.createmchCallForChannel(createBean1);
			//绑定一个渠道与另外一个渠道绑定
			bindmchBean bindmchBean=GodmchManageCallService.InitbindmchBean(mchId_agent, createCodeCall.getCode());
			GodmchManageCallService.bindmchcall(bindmchBean);
			
			String title="title1";
			String wc="wc2";
			//商户1
			CreateCodeBean ccbean = GodmchManageCallService.CreateAllMsgSellerMch();
			String code = GodmchManageCallService.createCodeCall(ccbean).getCode();
			Integer agentid = GodmchManageCallService.CreateSellerMch(code);
			GodmchManageCallService.editMchInfo(ccbean.getMchId(),title, DGUserCallService.DefImg2,wc);
			//商户2
			CreateCodeBean ccbean2 = GodmchManageCallService.CreateAllMsgSellerMch();
			String code2 = GodmchManageCallService.createCodeCall(ccbean2).getCode();
			Integer agentid2 = GodmchManageCallService.CreateSellerMch(code2);
			GodmchManageCallService.editMchInfo(ccbean2.getMchId(),title, DGUserCallService.DefImg2,wc);
			
			//公共小程序切换 成独立小程序
			shareTypeBbean.setMchId(mchId);
			shareTypeBbean.setMchShareType(5);//独立小程序（继承版）
			shareTypeBbean.setMchStatus(0);
			shareTypeBbean.setRemark("小程序 变为独立小程序（继承版）");
			//新字段
			shareTypeBbean.setPayMode(2);//支付方式:微信支付通道1：飞界国际2：飞界国际电子商务3：盛付通
			shareTypeBbean.setMchSideBuy(1);//商家端购买1：二维码购买 2：直接购买
			shareTypeBbean.setDualMode(0);//双店模式0：正常模式（默认）1：双店模式
			shareTypeCall.setData(shareTypeBbean);
			shareTypeCall.callService();
			Thread.sleep(3000);
			
			listbyidmchbean.setMchIds(Arrays.asList(ccbean.getMchId(),ccbean2.getMchId(),mchId_agent));
			listbyidmchcall.setData(listbyidmchbean);
			listbyidmchcall.callService();			
			Logger.verifyEquals("200", listbyidmchcall.getString("status"), "验证status");
			checkVerify(listbyidmchbean.getMchIds());
			
			List<MchInfoVo> rminfos = listbyidmchcall.getResult();
			MchInfoVo rminfo =rminfo = rminfos.stream().filter(r->r.getMchId().equals(mchId_agent)).findFirst().get();
			Logger.verifyEquals(5, rminfo.getmchShareType(), "验证分享类型是独立小程序（继承版）时上级商户 mchShareType");
			Logger.verifyEquals(mchId, Integer.parseInt(rminfo.getParentMchId()), "验证分享类型是独立小程序（继承版）时上级商户 ParentMchId");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_listbyidmch_011() {
		Logger.start(true,"商户信息(批量),验证商户ids集合都存在,创建渠道-小程序切换成 独立小程序（继承版），mchShareType=1 变为 mchShareType=5,返回上级商户Id parentMchId,渠道设置5后，下面的子代理都更新为5 ");
		try {
			
			String title="title1";
			String wc="wc2";
			//商户1
			CreateCodeBean ccbean = GodmchManageCallService.CreateAllMsgSellerMch();
			String code = GodmchManageCallService.createCodeCall(ccbean).getCode();
			Integer agentid = GodmchManageCallService.CreateSellerMch(code);
			GodmchManageCallService.editMchInfo(ccbean.getMchId(),title, DGUserCallService.DefImg2,wc);
			//商户2
			CreateCodeBean ccbean2 = GodmchManageCallService.CreateAllMsgSellerMch();
			String code2 = GodmchManageCallService.createCodeCall(ccbean2).getCode();
			Integer agentid2 = GodmchManageCallService.CreateSellerMch(code2);
			GodmchManageCallService.editMchInfo(ccbean2.getMchId(),title, DGUserCallService.DefImg2,wc);
			
			//公共小程序切换 成独立小程序
			shareTypeBbean.setMchId(ccbean.getMchId());
			shareTypeBbean.setMchShareType(5);//独立小程序（继承版）
			shareTypeBbean.setMchStatus(0);
			shareTypeBbean.setRemark("小程序 变为独立小程序（继承版）");
			//新字段
			shareTypeBbean.setPayMode(2);//支付方式:微信支付通道1：飞界国际2：飞界国际电子商务3：盛付通
			shareTypeBbean.setMchSideBuy(1);//商家端购买1：二维码购买 2：直接购买
			shareTypeBbean.setDualMode(0);//双店模式0：正常模式（默认）1：双店模式
			
			shareTypeCall.setData(shareTypeBbean);
			shareTypeCall.callService();
			Thread.sleep(3000);
			
			listbyidmchbean.setMchIds(Arrays.asList(ccbean.getMchId(),ccbean2.getMchId()));
			listbyidmchcall.setData(listbyidmchbean);
			listbyidmchcall.callService();			
			Logger.verifyEquals("200", listbyidmchcall.getString("status"), "验证status");
			checkVerify(listbyidmchbean.getMchIds());
			Logger.verifyNotNull( listbyidmchcall.getResult().get(0).getExpiredTime(), "验证ExpiredTime");
			Logger.verifyEquals(2, listbyidmchcall.getResult().get(0).getStatus(), "验证Status");

			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_listbyidmch_012() {
		Logger.start(true,"商户信息(批量),验证是双店模式,返回正常");
		try {
			String title="title1";
			String wc="wc2";
			CreateCodeBean ccbean = GodmchManageCallService.CreateAllMsgSellerMch();
			//String code = GodmchManageCallService.createCodeCall(ccbean).getCode();
			//Integer agentid = GodmchManageCallService.CreateSellerMch(code);
			//GodmchManageCallService.editMchInfo(ccbean.getMchId(),title, DGUserCallService.DefImg2,wc);
			 //设置双店模式
			setShareTypeBean setBean=GodmchManageCallService.initsetShareTypeV2(ccbean.getMchId());
			GodmchManageCallService.setShareTypeV2Call(setBean);
			
			listbyidmchbean.setMchIds(Arrays.asList(ccbean.getMchId()));
			listbyidmchcall.setData(listbyidmchbean);
			listbyidmchcall.callService();			
			Logger.verifyEquals("200", listbyidmchcall.getString("status"), "验证status");
			checkVerify(listbyidmchbean.getMchIds());
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_listbyidmch_013() {
		Logger.start(true,"商户信息(批量),验证纯渠道设置盛付通 payChannel=2,返回成功");
		try {

			Integer mchId_channl = GodmchManageCallService.CreateSellerMch();
			
			setShareTypeBean setShareTypeBean=GodmchManageCallService.initsetShareTypeV2(mchId_channl);
			setShareTypeBean.setPayMode(3);//支付方式:微信支付通道1：飞界国际2：飞界国际电子商务3：盛付通 4:飞界国际贸易
			GodmchManageCallService.setShareTypeV2Call(setShareTypeBean);
			
			listbyidmchbean.setMchIds(Arrays.asList(mchId_channl));
			listbyidmchcall.setData(listbyidmchbean);
			listbyidmchcall.callService();			
			Logger.verifyEquals("200", listbyidmchcall.getString("status"), "验证status");
			checkVerify(listbyidmchbean.getMchIds());
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_listbyidmch_014() {
		Logger.start(true,"商户信息(批量),验证独立商户,返回正常");
		try {

			createIndepMchBean createBean=GodmchManageCallService.InitCreateIndepMchBean();
			createIndepMchCall createCall=GodmchManageCallService.CreateIndepMchCall(createBean);
			
			listbyidmchbean.setMchIds(Arrays.asList(createCall.getmchId()));
			listbyidmchcall.setData(listbyidmchbean);
			listbyidmchcall.callService();			
			Logger.verifyEquals("200", listbyidmchcall.getString("status"), "验证status");
			checkVerify(listbyidmchbean.getMchIds(),true);
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_listbyidmch_015() {
		Logger.start(true,"商户信息,验证商户id存在,独立商户代理,返回正常");
		try {

			createIndepMchBean createBean=GodmchManageCallService.InitCreateIndepMchBean();
			createIndepMchCall createCall=GodmchManageCallService.CreateIndepMchCall(createBean);
			applyAgentCall applyAgentCall=GodmchManageCallService.applyAndapproveAgent(createCall.getmchId());
			
			listbyidmchbean.setMchIds(Arrays.asList(applyAgentCall.getAgentId()));
			listbyidmchcall.setData(listbyidmchbean);
			listbyidmchcall.callService();			
			Logger.verifyEquals("200", listbyidmchcall.getString("status"), "验证status");
			checkVerify(listbyidmchbean.getMchIds(),false);
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_listbyidmch_016() {
		Logger.start(true,"商户信息,验证商户id存在,独立商户代理,返回正常");
		try {

			createIndepMchBean createBean=GodmchManageCallService.InitCreateIndepMchBean();
			createIndepMchCall createCall=GodmchManageCallService.CreateIndepMchCall(createBean);
			//applyAgentCall applyAgentCall=GodmchManageCallService.applyAndapproveAgent(createCall.getmchId());
			Integer mchId=createCall.getmchId();
			Thread.sleep(5000);//休眠目的是为了创建独立商户，把对应的配置  同步到用户那边，然后用户 拿到配置再创建代理
			//2：申请代理
			applyAgentBean applyBean=GodmchManageCallService.InitApplyAgentBean();
			applyBean.setCountry("CHN");
			applyBean.setMchId(mchId);
			applyBean.setAppKey("appsqSeller_"+mchId);
			applyAgentCall applyCall=GodmchManageCallService.ApplyAgentCall(applyBean);
			//代理类型
			createagentBean agentBean=GodmchManageCallService.InitCreateAgentTypeBean(applyBean.getMchId());
			createagentCall agentCall=GodmchManageCallService.CreateAgentTypeCall(agentBean);
			//查询代理类型
			Map<String,Object> map=new HashMap();
			map.put("mchId", applyBean.getMchId());
			List<agent_type> list=GodmchManageCallService.agentTypeWapper.selectby(map);
			//3:审核代理
			approveAgentBean approveAgentBean=new approveAgentBean();
			approveAgentBean.setMchId(applyBean.getMchId());
			approveAgentBean.setAgentId(applyCall.getAgentId());
			approveAgentBean.setAgentType(list.get(0).getAgentType());
			approveAgentBean.setAgentMode(1);
		
			GodmchManageCallService.ApproveAgentCall(approveAgentBean);
			
			listbyidmchbean.setMchIds(Arrays.asList(applyCall.getAgentId()));
			listbyidmchcall.setData(listbyidmchbean);
			listbyidmchcall.callService();			
			Logger.verifyEquals("200", listbyidmchcall.getString("status"), "验证status");
			checkVerify(listbyidmchbean.getMchIds(),false);
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_listbyidmch_017() {
		Logger.start(true,"商户信息,验证商户id存在,微信HipoPay支付通道 payMode=0：不支持HipoPay");
		try {
			String title="title1";
			String wc="wc2";
			CreateCodeBean ccbean = GodmchManageCallService.CreateAllMsgSellerMch();
			String code = GodmchManageCallService.createCodeCall(ccbean).getCode();
			Integer agentid = GodmchManageCallService.CreateSellerMch(code);
			GodmchManageCallService.editMchInfo(ccbean.getMchId(),title, DGUserCallService.DefImg2,wc);
			
			//公共小程序切换 成独立小程序
			shareTypeBbean=GodmchManageCallService.initsetShareTypeV2(ccbean.getMchId());
			shareTypeBbean.setMchId(ccbean.getMchId());
			shareTypeBbean.setPayMode(0);//不支持HipoPay
			shareTypeCall.setData(shareTypeBbean);
			shareTypeCall.callService();
			
			listbyidmchbean.setMchIds(Arrays.asList(ccbean.getMchId()));
			listbyidmchcall.setData(listbyidmchbean);
			listbyidmchcall.callService();		
			
			checkVerify(listbyidmchbean.getMchIds());
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_listbyidmch_018() {
		Logger.start(true,"商户信息,验证商户id存在,微信国内支付通道 domesticPayMode=0：不支持 微信国内支付通道");
		try {
			String title="title1";
			String wc="wc2";
			CreateCodeBean ccbean = GodmchManageCallService.CreateAllMsgSellerMch();
			String code = GodmchManageCallService.createCodeCall(ccbean).getCode();
			Integer agentid = GodmchManageCallService.CreateSellerMch(code);
			GodmchManageCallService.editMchInfo(ccbean.getMchId(),title, DGUserCallService.DefImg2,wc);
			
			//公共小程序切换 成独立小程序
			shareTypeBbean=GodmchManageCallService.initsetShareTypeV2(ccbean.getMchId());
			shareTypeBbean.setMchId(ccbean.getMchId());
			shareTypeBbean.setDomesticPayMode(0);//不支持微信国内支付
			shareTypeCall.setData(shareTypeBbean);
			shareTypeCall.callService();
			
			listbyidmchbean.setMchIds(Arrays.asList(ccbean.getMchId()));
			listbyidmchcall.setData(listbyidmchbean);
			listbyidmchcall.callService();		
			
			checkVerify(listbyidmchbean.getMchIds());
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_listbyidmch_023() {
		Logger.start(true,"商户信息,验证商户id存在,微信国内支付通道 domesticPayMode=1：盛付通");
		try {
			String title="title1";
			String wc="wc2";
			CreateCodeBean ccbean = GodmchManageCallService.CreateAllMsgSellerMch();
			String code = GodmchManageCallService.createCodeCall(ccbean).getCode();
			Integer agentid = GodmchManageCallService.CreateSellerMch(code);
			GodmchManageCallService.editMchInfo(ccbean.getMchId(),title, DGUserCallService.DefImg2,wc);
			
			//公共小程序切换 成独立小程序
			shareTypeBbean=GodmchManageCallService.initsetShareTypeV2(ccbean.getMchId());
			shareTypeBbean.setMchId(ccbean.getMchId());
			shareTypeBbean.setDomesticPayMode(1);//盛付通
			shareTypeCall.setData(shareTypeBbean);
			shareTypeCall.callService();
			
			listbyidmchbean.setMchIds(Arrays.asList(ccbean.getMchId()));
			listbyidmchcall.setData(listbyidmchbean);
			listbyidmchcall.callService();		
			
			checkVerify(listbyidmchbean.getMchIds());
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_listbyidmch_024() {
		Logger.start(true,"商户信息,验证商户id存在,可以发布境内商品 pulishDomestic=true");
		try {
			String title="title1";
			String wc="wc2";
			CreateCodeBean ccbean = GodmchManageCallService.CreateAllMsgSellerMch();
			String code = GodmchManageCallService.createCodeCall(ccbean).getCode();
			Integer agentid = GodmchManageCallService.CreateSellerMch(code);
			GodmchManageCallService.editMchInfo(ccbean.getMchId(),title, DGUserCallService.DefImg2,wc);
			
			//公共小程序切换 成独立小程序
			shareTypeBbean=GodmchManageCallService.initsetShareTypeV2(ccbean.getMchId());
			shareTypeBbean.setMchId(ccbean.getMchId());
			shareTypeBbean.setPulishDomestic(true);//可以发布境内商品
			shareTypeCall.setData(shareTypeBbean);
			shareTypeCall.callService();
			
			listbyidmchbean.setMchIds(Arrays.asList(ccbean.getMchId()));
			listbyidmchcall.setData(listbyidmchbean);
			listbyidmchcall.callService();		
			
			Logger.verifyEquals("200", listbyidmchcall.getString("status"), "验证status");
			Logger.verifyEquals(true, listbyidmchcall.getString("msg").contains("请求成功"), "验证msg");
			
			checkVerify(listbyidmchbean.getMchIds());
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_listbyidmch_025() {
		Logger.start(true,"商户信息,验证商户id存在,不可以发布境内商品 pulishDomestic=false");
		try {
			String title="title1";
			String wc="wc2";
			CreateCodeBean ccbean = GodmchManageCallService.CreateAllMsgSellerMch();
			String code = GodmchManageCallService.createCodeCall(ccbean).getCode();
			Integer agentid = GodmchManageCallService.CreateSellerMch(code);
			GodmchManageCallService.editMchInfo(ccbean.getMchId(),title, DGUserCallService.DefImg2,wc);
			
			//公共小程序切换 成独立小程序
			shareTypeBbean=GodmchManageCallService.initsetShareTypeV2(ccbean.getMchId());
			shareTypeBbean.setMchId(ccbean.getMchId());
			shareTypeBbean.setPulishDomestic(false);//不可以发布境内商品
			shareTypeCall.setData(shareTypeBbean);
			shareTypeCall.callService();
			
			listbyidmchbean.setMchIds(Arrays.asList(ccbean.getMchId()));
			listbyidmchcall.setData(listbyidmchbean);
			listbyidmchcall.callService();		
			
			checkVerify(listbyidmchbean.getMchIds());
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_listbyidmch_026() {
		Logger.start(true,"商户信息,验证商户id存在,masterChainShopId连锁店、wechatDirectPayMode微信直连");
		try {
//			String title="title1";
//			String wc="wc2";
//			CreateCodeBean ccbean = GodmchManageCallService.CreateAllMsgSellerMch();
//			String code = GodmchManageCallService.createCodeCall(ccbean).getCode();
//			Integer agentid = GodmchManageCallService.CreateSellerMch(code);
//			GodmchManageCallService.editMchInfo(ccbean.getMchId(),title, DGUserCallService.DefImg2,wc);
//			
//			//公共小程序切换 成独立小程序
//			shareTypeBbean=GodmchManageCallService.initsetShareTypeV2(ccbean.getMchId());
//			shareTypeBbean.setMchId(ccbean.getMchId());
//			shareTypeBbean.setPulishDomestic(false);//不可以发布境内商品
//			shareTypeBbean.setMchId(masterChainShopId_wechatDirectPayMode);
//			shareTypeCall.setData(shareTypeBbean);
//			shareTypeCall.callService();
			
			listbyidmchbean.setMchIds(Arrays.asList(masterChainShopId_wechatDirectPayMode));
			listbyidmchcall.setData(listbyidmchbean);
			listbyidmchcall.callService();		
			
			checkVerify(listbyidmchbean.getMchIds());
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
}